package chapter7;

import java.util.*;
import java.util.concurrent.CountDownLatch;

/**
 * @author yuh
 * @date 2018/5/3 16:39
 * @description
 */
public class RemoveRepeat {

    public static void main(String[] args) throws InterruptedException {
        List<Integer> list = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            list.add(i);
            list2.add(i + 8);
        }



       /* System.out.println(list);
        System.out.println(list2);

        System.out.println(list2.subList(list2.indexOf(list.get(list.size() - 1)) + 1, list2.size()));*/


       /*

        //list.stream().mapToInt(a -> a + 1).forEach(a-> System.out.println(a));
        CountDownLatch latch = new CountDownLatch(1000);
        Set set = Collections.synchronizedSet(new HashSet<>());
        long l = System.currentTimeMillis();
        for (int i = 0; i < 1000; i++) {
            new java.lang.Thread(() -> {
                set.add(Thread.getInstance());
                latch.countDown();
            }).start();
        }
        latch.await();
        long l1 = System.currentTimeMillis();
        System.out.println(set.size());
        System.out.println(set);
        System.out.println(l1 - l);

        */


        System.out.println(isSubSequence("abc","bcd"));
    }

    static boolean isSubSequence(String a,String b){
        if("".equals(b)){
            return true;
        }else if("".equals(a)){
            return false;
        }else if(a.charAt(0) == b.charAt(0)){
            return isSubSequence(a.substring(1),b.substring(1));
        }else{
            return isSubSequence(a.substring(1),b);
        }
    }

}
